package com.sc.web.gwt.client.presenter.mapper;

import com.google.gwt.activity.shared.Activity;
import com.google.gwt.place.shared.Place;
import com.sc.web.gwt.client.ClientFactory;
import com.sc.web.gwt.client.place.AdministratorWidgetPlace;
import com.sc.web.gwt.client.place.AgentWidgetPlace;
import com.sc.web.gwt.client.place.LoginWidgetPlace;
import com.sc.web.gwt.client.place.RegisterWidgetPlace;
import com.sc.web.gwt.client.presenter.AdministratorActivity;
import com.sc.web.gwt.client.presenter.AgentActivity;
import com.sc.web.gwt.client.presenter.LoginActivity;
import com.sc.web.gwt.client.presenter.RegisterActivity;

public class HomeActivityMapper implements com.google.gwt.activity.shared.ActivityMapper {
    private ClientFactory clientFactory;

    public HomeActivityMapper(ClientFactory clientFactory) {
        super();
        this.clientFactory = clientFactory;
    }

    public Activity getActivity(Place place) {
        if (place instanceof AdministratorWidgetPlace) {
            return new AdministratorActivity((AdministratorWidgetPlace) place, clientFactory);
        }
        if (place instanceof LoginWidgetPlace) {
            return new LoginActivity((LoginWidgetPlace) place, clientFactory);
        }
        if (place instanceof RegisterWidgetPlace) {
            return new RegisterActivity((RegisterWidgetPlace) place, clientFactory);
        }
        if (place instanceof AgentWidgetPlace) {
            return new AgentActivity((AgentWidgetPlace) place, clientFactory);
        }
        return null;
    }
}
